import request from '@/utils/request';

/**
 *    管理员API
 */
export default {
	// 获取忘记密码验证码
	getAdminForgetPassCode(email) {
		return request('/admin/forgetPassCode', { email }, 'get');
	},

	// 忘记密码
	adminForgetPass(data) {
		return request('/admin/forgetPass', data, 'post');
	},

	//获取个人信息
	getUserInfo() {
		return request('/admin/userInfo', {}, 'get');
	},

	//修改个人信息
	updateUserInfo(data) {
		return request('/admin/updateInfo', data, 'post');
	},

	//获取修改邮箱验证码
	getModifyEmailCode(email) {
		return request('/admin/getUpdateEmailCode', { email }, 'get');
	},

	//修改邮箱
	updateEmail(data) {
		return request('/admin/updateEmail', data, 'post');
	},

	//上传头像
	uploadLogo(data) {
		return request('/admin/uploadLogo', data, 'post', {
			headers: {
				'Content-Type': 'multipart/form-data'
			}
		});
	},

	//修改密码
	modifyPass(data) {
		return request('/admin/modifyPass', data, 'post');
	},

	//获取未审批房源
	getPendingHouses(pageNo, pageSize) {
		return request(`/admin/getPendingHouses/${pageNo}/${pageSize}`, {}, 'get');
	},

	//审核房源
	auditHouse(data) {
		return request('/admin/auditHouse', data, 'post');
	},

	//房源ID尝试锁定房源
	tryLockHouse(houseId) {
		return request(`/admin/tryLockHouse/${houseId}`, {}, 'post');
	},

	//获取我审核的房源
	getMyAuditHouses(pageNo, pageSize) {
		return request(`/admin/getMyAuditHouses/${pageNo}/${pageSize}`, {}, 'get');
	},

	//下架房源---更新房源状态为已下架
	removeHouse(data) {
		return request('/admin/removeHouse', data, 'post');
	},

	//获取所有用户
	getAllUsers(pageNo, pageSize) {
		return request(`/admin/getAllUsers/${pageNo}/${pageSize}`, {}, 'get');
	},

	//获取所有房东
	getAllLandlords(pageNo, pageSize) {
		return request(`/admin/getAllLandlords/${pageNo}/${pageSize}`, {}, 'get');
	},

	//禁用用户
	disableUser(data) {
		return request('/admin/disableUser', data, 'post');
	},

	//恢复用户
	enableUser(data) {
		return request('/admin/enableUser', data, 'post');
	},

	//禁用房东
	disableLandlord(data) {
		return request('/admin/disableLandlord', data, 'post');
	},

	//恢复房东
	enableLandlord(data) {
		return request('/admin/enableLandlord', data, 'post');
	},

	//获取总览统计数据
	getOverviewData() {
		return request('/admin/getOverview', {}, 'get');
	},

	//获取趋势统计数据
	getTrendData(type, startDate, endDate, granularity) {
		return request('/admin/getTrend', { type, startDate, endDate, granularity }, 'get');
	},

	//获取用户行为统计数据
	getUserBehaviorData(metric, startDate, endDate, granularity) {
		return request('/admin/getUserBehavior', { metric, startDate, endDate, granularity }, 'get');
	},

	//获取房东运营情况统计数据：统计每个房东的房源发布数量及预约记录数量，帮助评估房东运营情况
	getLandlordPerformance() {
		return request('/admin/getLandlordPerformance', {}, 'get');
	},

	//获取房源在不同地理区域的分布统计数据 传入参数 type 为 "business" 或 "subway"
	getHouseByLocation(type) {
		return request('/admin/getHouseByLocation', { type }, 'get');
	}
};
